In [1]:
infile = open('data/p081_matrix.txt', 'r');
matrix = []
for line in infile:
row = list(map(int, line.split(',')))
matrix += [row]
for i in range(79):
matrix[0][i+1] += matrix[0][i]
matrix[i+1][0] += matrix[i][0]
for i in range(79):
for j in range(79):
matrix[i+1][j+1] += min(matrix[i][j+1], matrix[i+1][j])
print(matrix[79][79])
In [ ]: